import random
import string

prev = None
class PassGen:
	def __init__(self, plength=8):
		self.puncs = '!#$%&*+-.?@'
		self.plength = plength
		self.clength = self.plength/4
		self.plength = self.plength - self.clength
		self.vow = "aeiuoAEIOU"

	def gen_pass(self):
		ran_char = random.choice(string.digits+ string.lowercase+ string.uppercase)
		ran_pass = ''
		while(len(ran_pass)!=self.plength):
			ran_char = random.choice(string.digits+ string.lowercase+ string.uppercase)
			if self._accept(ran_char):
				ran_pass += ran_char
		ran_pass += self._get_punc()
		return ran_pass
	
	def _get_punc(self):
		return ''.join(random.choice(self.puncs) for ch in range(self.clength))

	def _accept(self, char):
		global prev
		if prev is None:
			return True
		if char in self.vow and prev in self.vow:
			prev = char
			return True
		return False


if __name__ == '__main__':
	pg = PassGen(8)
	print pg.gen_pass()	
